import { createWebHashHistory, createRouter } from "vue-router";
import Home from "./views/Home.vue";
import Doc from "./views/Doc.vue";
import SwichDemo from "./components/SwichDemo.vue";
import Button from "./components/Button.vue";
import Dialog from "./components/Dialog.vue";
import TabsDemo from "./components/TabsDemo.vue";
import { h } from 'vue';
import Markdown from './components/MarkDown.vue';
import GetStarted from './markdown/GetStarted.md'
import intro from './markdown/intro.md'
import install from './markdown/Install.md'

const history = createWebHashHistory();
const md = string => h(Markdown, { content:string, key: string })
export const router = createRouter({
  history: history,
  routes: [
    { path: "/", component: Home },
    {
      path: "/doc",
      component: Doc,
      children: [
        { path: "", redirect:'/doc/intro' },
        { path: "intro", component: md(intro) },
        { path: "get-started", component: md(GetStarted) },
        { path: "install", component: md(install) },
        { path: "switch", component: SwichDemo },
        { path: "button", component: Button },
        { path: "dialog", component: Dialog },
        { path: "tab", component: TabsDemo },
      ],
    },
  ],
});
router.afterEach(() => {
  console.log("路由切换了");
});
